﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace iControl.Windows
{
	/// <summary>
	/// Interaction logic for AboutWindow.xaml
	/// </summary>
	public partial class AboutWindow : Window
    {
        #region Variable Declaration
        private System.Windows.Media.Animation.Storyboard _HideAnimationStoryBoard;
        #endregion

        #region Constructor
        public AboutWindow()
		{
			this.InitializeComponent();

            _HideAnimationStoryBoard = this.FindResource("HideAnimation") as System.Windows.Media.Animation.Storyboard;
            _HideAnimationStoryBoard.Completed += new EventHandler(HideAnimation_Completed);
        }
        #endregion

        #region Event Handlers
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            lblVersion.Content = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            
        }
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if( e.Key == Key.Escape )
                this.Close();
        }

        private void btnCloseX_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void DragWindow(object sender, MouseButtonEventArgs e)
        {
            DragMove();
        }

        private void HideAnimation_Completed(object sender, EventArgs e)
        {
            base.Hide();
            this.WindowState = WindowState.Minimized;
        }
        #endregion

        #region Methods
        public new void Show()
        {
            this.Opacity = 0;
            base.Show();

            var showAnimation = this.FindResource("ShowAnimation") as System.Windows.Media.Animation.Storyboard;
            showAnimation.Begin(this);

        }
        public new void Close()
        {
            _HideAnimationStoryBoard.Begin(this);
        }
        #endregion  

        private void btnDonate_Click(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5775631");
            btnOK_Click(sender, e);
        }
    }
}